﻿using System;
using System.Windows.Forms;
using Arete;

namespace WcfEventWinFormsClient
{
    public partial class Form1 : Form
    {
        internal void ShowMessage(string message)
        {
            if (tbResults.InvokeRequired)
                tbResults.BeginInvoke(new Action<string>(ShowMessage),
                    new object[] {message});
            else tbResults.Text = message + 
                Environment.NewLine + 
                tbResults.Text;
        }

        public Form1() { InitializeComponent(); }

        private void Subscribe(object sender, EventArgs e)   { AppMain.Proxy.SubscribeEvent(); }

        private void FireEvent(object sender, EventArgs e)   { AppMain.Proxy.DoSomethingAndFireEvent(); }

        private void SendMessage(object sender, EventArgs e) { AppMain.Proxy.SendMessageAndFireEvent(tbMessage.Text); }
    }
}
